﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true"
    EnableEventValidation="false" CodeBehind="MortgageUI.aspx.cs" Inherits="Mortgage.Form.MortgageUI" %>

<%@ Register Src="~/UserControl/ctrPager.ascx" TagPrefix="custom" TagName="Pager" %>
<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="server">
    <title>Quản lý dữ liệu </title>
    <script type="text/javascript" src='<%= ResolveClientUrl("~/Scripts/jquery-window-5.03/jquery.window.min.js") %>'></script>
    <script type="text/javascript">
        $(document).ready(function () {

            $('.popup').click(function () {
                var urlPopup = $(this).attr('href');

                var popup = window.open(urlPopup,
                       "mywindow", "menubar=0,resizable=0," +
                       "width=940,height=650,toolbars=0,resize=0");

                return false;
            });

        });
    </script>
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div class="filter">
        <label title="Số đơn:" for="fldFltSerialNo">
            No:</label>
        <asp:TextBox ID="fldFltSerialNo" runat="server" MaxLength="50" Style="width: 50px" />
        <%-- <ajaxtoolkit:TextBoxWatermarkExtender ID="tbmfldFltSerialNo" runat="server" TargetControlID="fldFltSerialNo"
            WatermarkText="Nhập số đơn cầm" WatermarkCssClass="watermarked" />--%>
        <label for="fldFltMortdate" title="Ngày">
            Ngày cầm(Start):</label>
        <asp:TextBox ID="fldFltMortdate" runat="server" CssClass="dtePicker" />
        <%-- <ajaxtoolkit:TextBoxWatermarkExtender ID="tbwfldFltMortdate" runat="server" TargetControlID="fldFltMortdate"
            WatermarkText="Nhập ngày cầm(Start)" WatermarkCssClass="watermarked" />--%>
        <label for="fldFltMortdate" title="Ngày">
            (End):</label>
        <asp:TextBox ID="fldFltMordateEnd" runat="server" CssClass="dtePicker" />
        <%-- <ajaxtoolkit:TextBoxWatermarkExtender ID="tbmfldFltMordateEnd" runat="server" TargetControlID="fldFltMordateEnd"
            WatermarkText="(End)" WatermarkCssClass="watermarked" />--%>
        <label for="fltFltCustomerName" title="Ngày">
            Tên người cầm:</label>
        <asp:TextBox ID="fltFltCustomerName" runat="server" />
        <%--    <ajaxtoolkit:TextBoxWatermarkExtender ID="tbwfltFltCustomerName" runat="server" TargetControlID="fltFltCustomerName"
            WatermarkText="Nhập tên người cầm" WatermarkCssClass="watermarked" />--%>
        <label for="fldFltItemName" title="Ngày">
            Tên vật cầm:</label>
        <asp:TextBox ID="fldFltItemName" runat="server" />
        <%-- <ajaxtoolkit:TextBoxWatermarkExtender ID="tbwfldFltItemName" runat="server" TargetControlID="fldFltItemName"
            WatermarkText="Nhập Tên vật cầm:" WatermarkCssClass="watermarked" />--%>
        <label for="fldFltItemName" title="Ngày">
            Trạng thái:</label>
        <asp:DropDownList ID="fldFltStatus" runat="server" AppendDataBoundItems="true" Width="100px"
            DataTextField="Value" DataValueField="ID">
            <asp:ListItem Text="" Value="-999" Selected="True"></asp:ListItem>
        </asp:DropDownList>
        <asp:Button ID="btnSearch" runat="server" Text="Filter(Lọc)" OnClick="btnFilter_Click" />
    </div>
    <div class="gridMortgage" id="gridMortgage" runat="server">
        <center>
            <table cellpadding="0" cellspacing="0" border="0">
                <tr>
                    <td>
                        <asp:GridView ID="grid" runat="server" AutoGenerateColumns="False" BackColor="White" 
                            BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" DataKeyNames="ID"
                            CellPadding="3" OnSelectedIndexChanged="grid_SelectedIndexChanged" EnableModelValidation="True">
                            <EmptyDataTemplate>
                                <div class="noData">
                                    Chưa có dữ liệu phiếu cầm!</div>
                            </EmptyDataTemplate>
                            <Columns>
                                <asp:CommandField ShowSelectButton="True" SelectImageUrl="~/Images/icon/select.gif"
                                    ButtonType="Image" />
                                <asp:TemplateField>
                                    <ItemTemplate>
                                        <a href='<%# "BillUI.aspx?MorgId=" + Eval("ID") %>' class="popup">
                                            <img alt="Quan ly tien nhap" src="../Images/icon/bill.gif" />
                                        </a>
                                    </ItemTemplate>
                                </asp:TemplateField>
                                <asp:BoundField DataField="SerialNo" HeaderText="No" ItemStyle-Width="80px" ReadOnly="True"
                                    SortExpression="SerialNo">
                                    <ItemStyle Width="50px"></ItemStyle>
                                </asp:BoundField>
                                 <asp:BoundField DataField="ItemName" HeaderText="Tên vật cầm" ItemStyle-Width="200px" ReadOnly="True"
                                    SortExpression="ItemName">
                                    <ItemStyle Width="200px"></ItemStyle>
                                </asp:BoundField>
                                 <asp:BoundField DataField="CustomerName" HeaderText="Tên người" ItemStyle-Width="200px" ReadOnly="True"
                                    SortExpression="CustomerName">
                                    <ItemStyle Width="200px"></ItemStyle>
                                </asp:BoundField>
                                <asp:TemplateField HeaderText="Ngày" SortExpression="MorDate">
                                    <ItemTemplate>
                                        <asp:Label ID="lblMorDate" runat="server" Text='<%#   Eval("MorDate","{0:d}") %>'></asp:Label>
                                    </ItemTemplate>
                                    <ItemStyle Width="100px" />
                                </asp:TemplateField>
                                <asp:BoundField DataField="StatusCode" HeaderText="Tình trạng" ItemStyle-Width="80px"
                                    ReadOnly="True" SortExpression="StatusCode">
                                    <ItemStyle Width="80px"></ItemStyle>
                                </asp:BoundField>
                                <asp:BoundField DataField="MorMoney" HeaderText="Tiền cầm(VND)" ItemStyle-Width="150px"
                                    ItemStyle-CssClass="number" DataFormatString="{0:#,# VND}" ReadOnly="True" SortExpression="MorMoney">
                                    <ItemStyle Width="150px"></ItemStyle>
                                </asp:BoundField>
                                <asp:BoundField DataField="MoneyAmount" HeaderText="Tiền thu(VND)" ItemStyle-Width="150px"
                                    ItemStyle-CssClass="number" DataFormatString="{0:#,# VND}" ReadOnly="True" SortExpression="MoneyAmount">
                                    <ItemStyle Width="150px"></ItemStyle>
                                </asp:BoundField>
                                <asp:BoundField DataField="BillDate" HeaderText="Ngày đóng" ItemStyle-Width="150px"
                                    DataFormatString="{0:d}" ReadOnly="True" SortExpression="BillDate">
                                    <ItemStyle Width="150px"></ItemStyle>
                                </asp:BoundField>
                                <asp:BoundField DataField="InterestRate" HeaderText="Lãi suất(%)" ItemStyle-Width="80px"
                                    ReadOnly="True" SortExpression="InterestRate">
                                    <ItemStyle Width="80px"></ItemStyle>
                                </asp:BoundField>
                            </Columns>
                            <FooterStyle BackColor="White" ForeColor="#000066" />
                            <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
                            <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Center" />
                            <RowStyle ForeColor="#000066" />
                            <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                        </asp:GridView>
                    </td>
                </tr>
                <tr>
                    <td>
                        <custom:Pager ID="custPager" runat="server" OnPageChanged="custPager_PageChanged" />
                    </td>
                </tr>
            </table>
        </center>
    </div>
    <div class="detail">
        <fieldset>
            <legend>Nhập liệu hóa đơn/ phiếu cầm đồ</legend>
            <asp:Label ID="DialogMessMortgage" runat="server" CssClass="failureNotification" />
            <table style="vertical-align: top; width: 100%;">
                <thead>
                    <th style="width: 15%; text-align: right;">
                    </th>
                    <th style="width: 10%;">
                    </th>
                    <th style="width: 10%; text-align: right;">
                    </th>
                    <th style="width: 20%;">
                    </th>
                    <th style="width: 10%; text-align: right;">
                    </th>
                    <th style="width: 35%;">
                    </th>
                </thead>
                <tbody>
                    <tr>
                        <td class="label">
                            <label title="Số đơn:" for="fldSerialNo">
                                Số phiếu (No):<span class="required">*</span></label>
                        </td>
                        <td>
                            <asp:TextBox ID="fldSerialNo" runat="server" MaxLength="50"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="reqfldSerialNo" runat="server" ErrorMessage="*" ValidationGroup="detail"
                                Display="Dynamic" CssClass="failureNotification" ControlToValidate="fldSerialNo" />
                            <%--<ajaxtoolkit:TextBoxWatermarkExtender ID="tbwfldSerialNo" runat="server" TargetControlID="fldSerialNo"
                                WatermarkText="Nhập Số phiếu (No):" WatermarkCssClass="watermarked" />--%>
                        </td>
                        <td class="label">
                            <label for="" title="Ngày">
                                Ngày:<span class="required">*</span></label>
                        </td>
                        <td>
                            <asp:TextBox ID="fldMorDate" runat="server" CssClass="dtePicker" />
                            <asp:RequiredFieldValidator ID="reqfldMorDate" runat="server" ValidationGroup="detail"
                                Display="Dynamic" ErrorMessage="*" CssClass="failureNotification" ControlToValidate="fldMorDate" />
                            <%-- <ajaxtoolkit:TextBoxWatermarkExtender ID="tbwfldMorDate" runat="server" TargetControlID="fldMorDate"
                                WatermarkText="Nhập Số phiếu (No):" WatermarkCssClass="watermarked" />--%>
                        </td>
                        <td class="label">
                            Trạng thái:
                        </td>
                        <td>
                            <asp:Label ID="fldStatus" runat="server" /><asp:HiddenField ID="fldStatusId" runat="server" />
                        </td>
                    </tr>
                    <tr>
                        <td class="label">
                            <label title="Họ tên" for="fldCustumerName">
                                Họ tên:<span class="required">*</span></label>
                        </td>
                        <td>
                            <asp:TextBox ID="fldCustumerName" runat="server" MaxLength="50"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="reqfldCustomerName" runat="server" ErrorMessage="*"
                                Display="Dynamic" ValidationGroup="detail" CssClass="failureNotification" ControlToValidate="fldCustumerName" />
                            <%--  <ajaxtoolkit:TextBoxWatermarkExtender ID="tbwfldCustumerName" runat="server" TargetControlID="fldCustumerName"
                                WatermarkText="Nhập Họ tên" WatermarkCssClass="watermarked" />--%>
                        </td>
                        <td class="label">
                            <label for="fldCustomerPhone" title="Điện thọai">
                                Điện thọai:</label>
                        </td>
                        <td>
                            <asp:TextBox ID="fldCustomerPhone" runat="server" />
                            <%--<ajaxtoolkit:TextBoxWatermarkExtender ID="tbwfldCustomerPhone" runat="server" TargetControlID="fldCustomerPhone"
                                WatermarkText="Nhập Điện thọai" WatermarkCssClass="watermarked" />--%>
                        </td>
                        <td>
                            &nbsp;
                        </td>
                        <td>
                            <asp:DataList ID="lstStatus" runat="server" RepeatDirection="Horizontal" ShowFooter="False"
                                ShowHeader="False">
                                <ItemTemplate>
                                    <asp:Button ID="cmdStatusChange" runat="server" CommandArgument='<%#  Eval("Id") %>'
                                        OnClick="btnStatusMortgage_Click" Text='<%# Eval("Value") %>' />
                                </ItemTemplate>
                            </asp:DataList>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">
                            <label title="Địa chỉ" for="fldCustumerAddress">
                                Địa chỉ:
                            </label>
                        </td>
                        <td colspan="3">
                            <asp:TextBox ID="fldCustumerAddress" runat="server" MaxLength="500" Width="95%" />
                            <%-- <ajaxtoolkit:TextBoxWatermarkExtender ID="tbwfldCustumerAddress" runat="server" TargetControlID="fldCustumerAddress"
                                WatermarkText="Nhập Địa chỉ" WatermarkCssClass="watermarked" />--%>
                        </td>
                        <td class="label">
                            Thông tin tiền nhận.
                        </td>
                        <td>
                            <asp:HyperLink ID="hplBill" runat="server" CssClass="popup">
                                            <img alt="Quan ly tien nhap" src="../Images/icon/bill.gif" />
                            </asp:HyperLink>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">
                            <label title="Tên đồ cầm" for="fldItemName">
                                Tên đồ vật cầm:<span class="required">*</span></label>
                        </td>
                        <td colspan="3">
                            <asp:TextBox ID="fldItemName" runat="server" MaxLength="500" Width="95%" />
                            <asp:RequiredFieldValidator ID="reqfldItemName" runat="server" ValidationGroup="detail"
                                Display="Dynamic" ErrorMessage="*" CssClass="failureNotification" ControlToValidate="fldItemName" />
                            <%--  <ajaxtoolkit:TextBoxWatermarkExtender ID="tbwfldItemName" runat="server" TargetControlID="fldItemName"
                                WatermarkText="Nhập Tên đồ vật cầm" WatermarkCssClass="watermarked" />--%>
                        </td>
                        <td colspan="2" rowspan="4" style="vertical-align: top;">
                            <asp:GridView ID="gridBill" runat="server" AutoGenerateColumns="False"   
                                BorderColor="#CCCCCC" BorderStyle="None" BorderWidth="1px" DataKeyNames="ID" 
                                CellPadding="3" OnSelectedIndexChanged="grid_SelectedIndexChanged" EnableModelValidation="True">
                                <EmptyDataTemplate>
                                    <div class="noData">
                                        Chưa có dữ liệu thông tin tiền nhập (tiền lãi/ chuộc)!</div>
                                </EmptyDataTemplate>
                                <RowStyle BackColor="White" />
                                <Columns>
                                    <asp:TemplateField HeaderText="Ngày" SortExpression="BillDate">
                                        <ItemTemplate>
                                            <asp:Label ID="lblBillDate" runat="server" Text='<%#   Eval("BillDate","{0:d}") %>'></asp:Label>
                                        </ItemTemplate>
                                        <ItemStyle Width="150px" />
                                    </asp:TemplateField>
                                    <asp:TemplateField HeaderText="Lọai" SortExpression="BillType">
                                        <ItemTemplate>
                                            <asp:Label ID="lblBillType" runat="server" Text='<%# Mortgage.Utility.GetMorgageStatusCode(Convert.ToInt32(Eval("BillType")))   %>'></asp:Label>
                                        </ItemTemplate>
                                        <ItemStyle Width="100px" />
                                    </asp:TemplateField>
                                    <asp:BoundField DataField="MoneyAmount" HeaderText="Số tiền thu(VND)" ItemStyle-Width="150px"
                                        ItemStyle-CssClass="number" DataFormatString="{0:#,# VND}" ReadOnly="True" SortExpression="MorMoney">
                                        <ItemStyle Width="150px"></ItemStyle>
                                    </asp:BoundField>
                                </Columns>
                                <FooterStyle BackColor="White" ForeColor="#000066" />
                                <HeaderStyle BackColor="#006699" Font-Bold="True" ForeColor="White" />
                                <PagerStyle BackColor="White" ForeColor="#000066" HorizontalAlign="Center" />
                                <RowStyle ForeColor="#000066" />
                                <SelectedRowStyle BackColor="#669999" Font-Bold="True" ForeColor="White" />
                            </asp:GridView>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">
                            <label title="Lọai măt hàng" for="fldItemName">
                                Lọai mặt hàng:</label>
                        </td>
                        <td>
                            <asp:DropDownList ID="fldInterID" runat="server" DataTextField="Value" DataValueField="ID"
                                AutoPostBack="true" Width="95%" AppendDataBoundItems="true">
                                <asp:ListItem Text="" Value="-1"></asp:ListItem>
                            </asp:DropDownList>
                        </td>
                        <td class="label">
                            Lãi suất (%):<span class="required">*</span>
                        </td>
                        <td>
                            <asp:TextBox ID="fldInterestRate" runat="server" />
                            <asp:RequiredFieldValidator ID="reqfldInterestRate" runat="server" ValidationGroup="detail"
                                Display="Dynamic" ErrorMessage="*" CssClass="failureNotification" ControlToValidate="fldInterestRate" />
                            <ajaxtoolkit:FilteredTextBoxExtender ID="ftfldInterestRate" runat="server" TargetControlID="fldInterestRate"
                                FilterType=" Numbers" />
                            <%--  <ajaxtoolkit:TextBoxWatermarkExtender ID="tbwfldInterestRate" runat="server" TargetControlID="fldInterestRate"
                                WatermarkText="Nhập Lãi suất (%)" WatermarkCssClass="watermarked" />--%>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">
                            <label title="Số lượng tiền (cầm)" for="fldMorMoney">
                                Số lượng tiền (cầm):<span class="required">*</span></label>
                        </td>
                        <td>
                            <asp:TextBox ID="fldMorMoney" CssClass="number" runat="server" MaxLength="12" />
                            000(VND)
                            <asp:RangeValidator ID="reqfldMorMoney" runat="server" ValidationGroup="detail" Type="Currency"
                                Display="Dynamic" MinimumValue="1" MaximumValue="9999999999999" ErrorMessage="*"
                                CssClass="failureNotification" ControlToValidate="fldMorMoney" />
                            <ajaxtoolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender1" runat="server"
                                TargetControlID="fldMorMoney" FilterType=" Numbers" />
                            <%--   <ajaxtoolkit:TextBoxWatermarkExtender ID="tbwfldMorMoney" runat="server" TargetControlID="fldMorMoney"
                                WatermarkText="Nhập Số lượng tiền (cầm)" WatermarkCssClass="watermarked" />--%>
                        </td>
                        <td>
                            Số ngày hết hạn chuộc<span class="required">*</span>
                        </td>
                        <td>
                            <asp:TextBox ID="fldNumDayExpire" runat="server" />
                            <asp:RequiredFieldValidator ID="reqfldNumDayExpire" runat="server" ValidationGroup="detail"
                                Display="Dynamic" ErrorMessage="*" CssClass="failureNotification" ControlToValidate="fldNumDayExpire" />
                            <ajaxtoolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender2" runat="server"
                                TargetControlID="fldNumDayExpire" FilterType=" Numbers" />
                            <%--    <ajaxtoolkit:TextBoxWatermarkExtender ID="tbwfldNumDayExpire" runat="server" TargetControlID="fldNumDayExpire"
                                WatermarkText="Nhập Số ngày hết hạn chuộc" WatermarkCssClass="watermarked" />--%>
                        </td>
                    </tr>
                    <tr>
                        <td class="label">
                            <label title="Ghi chú" for="fldMorMoney">
                                Ghi chú:</label>
                        </td>
                        <td colspan="3">
                            <asp:TextBox ID="fldDescription" runat="server" TextMode="MultiLine" Width="95%" />
                            <%-- <ajaxtoolkit:TextBoxWatermarkExtender ID="tbwfldDescription" runat="server" TargetControlID="fldDescription"
                                WatermarkText="Nhập Ghi chú" WatermarkCssClass="watermarked" />--%>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <asp:CheckBox ID="chkKeepInsert" runat="server" Text="Giữ trạng thái tạo mới" />
                        </td>
                        <td colspan="3">
                            <asp:Button ID="btnDelete" runat="server" Text="Xóa" CssClass="btnDelete" CausesValidation="false"
                                OnClick="btnDeleteMortgage_Click" />
                            &nbsp;&nbsp;
                            <asp:Button ID="btnEdit" runat="server" Text="Cập nhật" CssClass="btnEdit" CausesValidation="false"
                                OnClick="btnEditMortgage_Click" />
                            &nbsp;&nbsp;
                            <asp:Button ID="btnNew" runat="server" Text="Tạo mới" CssClass="btnNew" CausesValidation="false"
                                OnClick="btnNewMortgage_Click" />
                            &nbsp;&nbsp;
                            <asp:Button ID="btnSave" runat="server" Text="Lưu" CssClass="btnSave" ValidationGroup="detail"
                                OnClick="btnSaveMortgage_Click" />
                            &nbsp;&nbsp;
                            <asp:Button ID="btnCancel" runat="server" Text="Huy" CssClass="btnCancel" CausesValidation="false"
                                OnClick="btnCancelMortgage_Click" />
                            <ajaxtoolkit:ConfirmButtonExtender ID="cfmDelete" runat="server" ConfirmText="Bạn có thực sự muốn xóa dữ liệu này?"
                                TargetControlID="btnDelete" />
                        </td>
                    </tr>
                </tbody>
            </table>
        </fieldset>
        <asp:HiddenField ID="fldID" runat="server" />
        <asp:HiddenField ID="fldEnmInterRateType" runat="server" />
    </div>
</asp:Content>
